home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
bit
/
src
/
ulib
/
hash.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
704b
|
27 lines
/***********************************************************************
* $Id: hash.c,v 0.51 1993/07/23 22:00:37 zhao Exp $
*
*. Copyright(c) 1993 by T.C. Zhao
* All rights reserved.
*.
* Simple hash function
***********************************************************************/
#if !defined(lint) && defined(F_ID)
char *id_hash = "$Id: hash.c,v 0.51 1993/07/23 22:00:37 zhao Exp $";
#endif
#ifndef HASHMAX
#define HASHMAX ((1 << 12) - 1)
#endif
int
hash(register const char *s)
{
register int val = 0;
while (*s)
val = 33 * val + *s++;
return ((val > 0) ? val : -val) % HASHMAX;
}